package com.qingke.demo.Date;

public class Date {
	private int day;
	private int month ;
	private int year ;
	
	public Date(int day,int month,int year){
		if((day<0||day>31) || (month<0||month>12) || (year<1900||year>9999)){
			System.out.println("Error");
			return;
		}
		this.day = day;
		this.month = month;
		this.year = year;
	}
	
	public int getDay(){
		return day;
	}
	
	public int getMonth(){
		return month;
	}
	
	public int getYear(){
		return year;
	}
	
	public void setDay(int day){
		if(day>31||day<0){
			System.out.println("Error");
			return;
		}
			
		this.day = day;
	}
	
	public void setMonth(int month){
		if(month>12||month<0){
			System.out.println("Error");
			return;
		}
		this.month = month;
	}
	
	public void setYear(int year){
		if(year>9999||year<1900){
			System.out.print("Error");
			return;
		}
		this.year = year;
	}
	
	public void setDate(int day,int month,int year){
		if((day<0||day>31) || (month<0||month>12) || (year<1900||year>9999)){
			System.out.println("Error");
			return;
		}
		this.day = day;
		this.month = month;
		this.year = year;
	}
	
	public String toString(){
		if(day<10){
			if(month<10)
				return "0"+day+"/0"+month+"/"+year;
			else
				return "0"+day+"/"+month+"/"+year;
		}else if(month<10)
			return day+"/0"+month+"/"+year;
		else
			return day+"/"+month+"/"+year;
	}
	
}
